﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CloudFranceTriple.Models;

namespace CloudFranceTriple.WebRole.Areas.Gaming.Controllers
{
    [CloudFranceTriple.WebRole.Filters.InitializeSimpleMembership]
    public class Bf3PlayerPropertyController : Controller
    {
        private cloudfrAboq2RsDMEntities db = new cloudfrAboq2RsDMEntities();

        //
        // GET: /Gaming/Bf3PlayerProperty/

        [Authorize(Roles = "RoleAdminGaming")]
        public ActionResult Index()
        {
            var bf3playerpropertyset = db.Bf3PlayerPropertySet.Include(b => b.PlayerOnGameSet);
            return View(bf3playerpropertyset.ToList());
        }

        //
        // GET: /Gaming/Bf3PlayerProperty/Details/5

        [Authorize(Roles = "RoleAdminGaming")]
        public ActionResult Details(int id = 0)
        {
            Bf3PlayerPropertySet bf3playerpropertyset = db.Bf3PlayerPropertySet.Find(id);
            if (bf3playerpropertyset == null)
            {
                return HttpNotFound();
            }
            return View(bf3playerpropertyset);
        }

        //
        // GET: /Gaming/Bf3PlayerProperty/Create

        [Authorize(Roles = "RoleAdminGaming")]
        public ActionResult Create()
        {
            ViewBag.GameId = new SelectList(db.PlayerOnGameSet, "GameId", "PlayerNickName");
            return View();
        }

        //
        // POST: /Gaming/Bf3PlayerProperty/Create

        [HttpPost]
        [ValidateAntiForgeryToken]
        [Authorize(Roles = "RoleAdminGaming")]
        public ActionResult Create(Bf3PlayerPropertySet bf3playerpropertyset)
        {
            if (ModelState.IsValid)
            {
                db.Bf3PlayerPropertySet.Add(bf3playerpropertyset);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.GameId = new SelectList(db.PlayerOnGameSet, "GameId", "PlayerNickName", bf3playerpropertyset.GameId);
            return View(bf3playerpropertyset);
        }

        //
        // GET: /Gaming/Bf3PlayerProperty/Edit/5

        [Authorize(Roles = "RoleAdminGaming")]
        public ActionResult Edit(int id = 0)
        {
            Bf3PlayerPropertySet bf3playerpropertyset = db.Bf3PlayerPropertySet.Find(id);
            if (bf3playerpropertyset == null)
            {
                return HttpNotFound();
            }
            ViewBag.GameId = new SelectList(db.PlayerOnGameSet, "GameId", "PlayerNickName", bf3playerpropertyset.GameId);
            return View(bf3playerpropertyset);
        }

        //
        // POST: /Gaming/Bf3PlayerProperty/Edit/5

        [HttpPost]
        [ValidateAntiForgeryToken]
        [Authorize(Roles = "RoleAdminGaming")]
        public ActionResult Edit(Bf3PlayerPropertySet bf3playerpropertyset)
        {
            if (ModelState.IsValid)
            {
                db.Entry(bf3playerpropertyset).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.GameId = new SelectList(db.PlayerOnGameSet, "GameId", "PlayerNickName", bf3playerpropertyset.GameId);
            return View(bf3playerpropertyset);
        }

        //
        // GET: /Gaming/Bf3PlayerProperty/Delete/5

        [Authorize(Roles = "RoleAdminGaming")]
        public ActionResult Delete(int id = 0)
        {
            Bf3PlayerPropertySet bf3playerpropertyset = db.Bf3PlayerPropertySet.Find(id);
            if (bf3playerpropertyset == null)
            {
                return HttpNotFound();
            }
            return View(bf3playerpropertyset);
        }

        //
        // POST: /Gaming/Bf3PlayerProperty/Delete/5

        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        [Authorize(Roles = "RoleAdminGaming")]
        public ActionResult DeleteConfirmed(int id)
        {
            Bf3PlayerPropertySet bf3playerpropertyset = db.Bf3PlayerPropertySet.Find(id);
            db.Bf3PlayerPropertySet.Remove(bf3playerpropertyset);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}